package com.ebarlas.fractal.util;

public class ArrayStack<E> {
    
    private static int DEFAULT_CAPACITY = 100;
    
    private int top;
    private Object[] array;
    
    public ArrayStack() {
        top = -1;
        array = new Object[DEFAULT_CAPACITY];
    }    
    
    public ArrayStack(int capacity) {
        top = -1;
        array = new Object[capacity];
    }
    
    public void push(E e) {
        array[++top] = e;
    }
    
    @SuppressWarnings("unchecked")
    public E pop() {
        return (E)array[top--];
    }
    
    public void clear() {
        top = -1;
    }
}
